import * as React from "react";

type OperationType =
/**
 * 键盘按下
 */
    | "KeyDown"
    /**
     * 键盘启动
     */
    | "KeyUp"
    /**
     * 鼠标移动到
     */
    | "MouseTo"
    /**
     * 鼠标左键点击
     */
    | "MouseLeftClick"
    /**
     * 鼠标右键点击
     */
    | "MouseRightClick"
    /**
     * 鼠标右键点击
     */
    | "Delay"


interface LOptionType {
    value: string,
    label: React.ReactNode
}

// 定义操作的方法
const OperationMethods = {
    // 例如，获取操作类型的描述
    getTypeDescription(type: OperationType): string {
        switch (type) {
            case 'KeyDown':
                return "键盘按下";
            case 'KeyUp':
                return "键盘放开";
            case 'MouseTo':
                return "鼠标移动到";
            case 'MouseLeftClick':
                return "鼠标左键点击";
            case 'MouseRightClick':
                return "鼠标右键点击";
            case 'Delay':
                return "延迟";
            default:
                return "未知操作类型";
        }
    },
    isTime(type: OperationType): boolean {
        return type !== 'MouseTo';

    },
    getDict(): LOptionType[] {
        return [
            {
                value: 'KeyDown',
                label: '键盘按下'
            },
            {
                value: 'KeyUp',
                label: '键盘放开'
            },
            {
                value: 'MouseTo',
                label: '鼠标移动到'
            },
            {
                value: 'MouseLeftClick',
                label: '鼠标左键点击'
            },
            {
                value: 'MouseRightClick',
                label: '鼠标右键点击'
            },
            {
                value: 'Delay',
                label: '延迟'
            },
        ]
    }
};

type OperationParamsType = | { time: number,key:string }
    | { screenX: number, screenY: number }

interface Operation {
    id: number,
    operation_type: OperationType,
    step: number,
    params: OperationParamsType,
    mark?:string,
    group_id:number,
}

interface Group {
    id: number,
    name: string,
    enable: boolean
}

export type {Operation, OperationType, Group, OperationParamsType, LOptionType}
export {OperationMethods}